import Vue from 'vue'
import VueRouter from 'vue-router'

const layout = () => import('@/views/layout')
const home = () => import('@/views/layout/home')
const category = () => import('@/views/layout/category')
const cart = () => import('@/views/layout/cart')
const user = () => import('@/views/layout/user')

const login = () => import('@/views/login')
const search = () => import('@/views/search')
const list = () => import('@/views/list')
const detail = () => import('@/views/detail')
const comment = () => import('@/views/comment')

const checkout = () => import('@/views/checkout')
const address = () => import('@/views/address')
const addressCreate = () => import('@/views/addressCreate')
const addressUpdate = () => import('@/views/addressUpdate')

const order = () => import('@/views/order')
const myCoupon = () => import('@/views/myCoupon')
const coupon = () => import('@/views/coupon')
const oderDetail = () => import('@/views/oderDetail')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: home
      },
      {
        path: '/category',
        component: category
      },
      {
        path: '/cart',
        component: cart
      },
      {
        path: '/user',
        component: user
      }
    ]
  },
  {
    path: '/login',
    component: login
  },
  {
    path: '/search',
    component: search
  },
  {
    path: '/list',
    component: list
  },
  {
    path: '/detail',
    component: detail
  },
  {
    path: '/comment',
    component: comment
  },
  {
    path: '/checkout',
    component: checkout
  },
  {
    path: '/address',
    component: address
  },
  {
    path: '/address/create',
    component: addressCreate
  },
  {
    path: '/address/update',
    component: addressUpdate
  },
  {
    path: '/order',
    component: order
  },
  {
    path: '/mycoupon',
    component: myCoupon
  },
  {
    path: '/coupon',
    component: coupon
  },
  {
    path: '/order/detail',
    component: oderDetail
  }
]

const router = new VueRouter({
  routes
})

export default router
